# -*- coding = utf-8 -*-
"""
 Author: 苏苏少年
 File：六间房.py
 Time: 2022/5/11 20:24
"""

import requests


url = 'https://v.6.cn/minivideo/getMiniVideoList.php?act=recommend&page=1&pagesize=20'

headers = {
    'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36'
}

res = requests.get(url=url,headers=headers)
# print(res.json())

data_list = res.json()['content']['list']
for data in data_list:
    title = data['title']
    playurl = data['playurl']
    # print(title)
    # print(playurl)

    # 保存数据!
    resulr = requests.get(playurl,headers=headers)
    with open('video/' + title + '.mp4', 'wb')as f:
        f.write(resulr.content)
        print('正在下载{}'.format(title))
